/**
 * Copyright 2005 The Apache Software Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.edi.runtime.component
{
	import mx.controls.Label;
	import com.edi.runtime.Event.*;
	
	/**
	 * 继承子Label,并实现接口.
	 * 用于自动分发数据和展示.
	 * 
	 */	
	public class EDILabel extends Label implements IEDIComponent
	{
		private var _field:String;
		private var _fieldtype:String;
		private var _fieldlength:int=0;
		public var notNull:Boolean=true;
		private var _table:String;
		private var _primaryKey:String="";
		
		public function EDILabel()
		{
			super();
		}
		/**
		 * 实现IEDIComponent接口的属性
		 * @param value
		 * 
		 */		
		public function set table(value:String):void
		{
			_table=value;
			EDIEventProxy.listenerDataRolling(value,this);
		}
		/**
		 * 实现IEDIComponent接口的属性
		 * @return 
		 * 
		 */		
		public function get table():String
		{return _table;}
		
		/**
		 * 实现IEDIComponent接口的属性
		 * @param value
		 * 
		 */		
		public function set primaryKey(value:String):void
		{_primaryKey=value;}
		/**
		 * 实现IEDIComponent接口的属性
		 * @return 
		 * 
		 */		
		public function get primaryKey():String
		{return _primaryKey;}

		/**
		 * 实现IEDIComponent接口的属性
		 * @param value
		 * 
		 */		
		public function set field(value:String):void
		{_field=value;}
		/**
		 * 实现IEDIComponent接口的属性
		 * @return 
		 * 
		 */		
		public function get field():String
		{return _field;}
		/**
		 * 实现IEDIComponent接口的属性，同时对录入数据的合法性进行检查
		 * @param value
		 * 
		 */		
		public function set fieldType(value:String):void
		{
			_fieldtype=value;
			
		}
		/**
		 * 实现IEDIComponent接口的属性
		 * @return 
		 * 
		 */		
		public function get fieldType():String
		{return _fieldtype;}
		
		/**
		 *  字段长度，同时对录入数据的合法性进行检查
		 * @return 
		 * 
		 */		
		public function get fieldLength():int
		{return _fieldlength;}
		/**
		 * 实现IEDIComponent接口的方法
		 * @param event
		 * 
		 */		
		public function dataRollingHandler(event:EDIDataEvent):void
		{
			text=event.value[field];
		}
		/**
		 * 实现IEDIComponent接口的属性
		 * @return 
		 * 
		 */		
		public function get ediValue():String
		{
			return text;
		}
		
	}
}